// https://static.geetest.com/static/js/slide.7.9.2.js

const CryptoJS = require('crypto-js')
const NodeRSA = require('node-rsa');
const crypto = require('crypto');


function random_t() {
    return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
}

function four_random_rt() {
    // return  '328b7dc4e9d22554'
    return random_t() + random_t() + random_t() + random_t();
}

// var encryKey = four_random_rt();

function genRSAesKey(data) {
    const public_key_1 = '00C1E3934D1614465B33053E7F48EE4EC87B14B95EF88947713D25EECBFF7E74C7977D02DC1D9451F79DD5D1C10C29ACB6A9B4D6FB7D0A0279B6719E1772565F09AF627715919221AEF91899CAE08C0D686D748B20A3603BE2318CA6BC2B59706592A9219D0BF05C9F65023A21D2330807252AE0066D59CEEFA5F2748EA80BAB81';
    const public_key_2 = '10001';
    const public_key = new NodeRSA();
    public_key.importKey({
        n: Buffer.from(public_key_1, 'hex'),
        e: parseInt(public_key_2, 16),
    }, 'components-public');
    const encrypted = crypto.publicEncrypt({
        key: public_key.exportKey('public'),
        padding: crypto.constants.RSA_PKCS1_PADDING
    }, Buffer.from(data));
    return encrypted.toString('hex');
}

function aesV(o_text, random_str) {
    var key = CryptoJS.enc.Utf8.parse(random_str);
    var iv = CryptoJS.enc.Utf8.parse("0000000000000000");
    var srcs = CryptoJS.enc.Utf8.parse(o_text);
    var encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    for (var r = encrypted, o = r.ciphertext.words, i = r.ciphertext.sigBytes, s = [], a = 0; a < i; a++) {
        var c = o[a >>> 2] >>> 24 - a % 4 * 8 & 255;
        s.push(c);
    }
    return s;
};


function $_FBm(t, e) {
    return t >> e & 1;
}

function $_EJu(t) {
    var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()";
    return t < 0 || t >= e.length ? '.' : e.charAt(t);
}


function h_m_$FCD(t, i) {
    var o = this;
    i || (i = o);
    var e = function (t, e) {
        for (var n = 0, r = 24 - 1; 0 <= r; r -= 1)
            1 === $_FBm(e, r) && (n = (n << 1) + $_FBm(t, r));
        return n;
    };
    var n = '', r = '', s = t["length"]
    for (var a = 0; a < s; a += 3) {
        var _;
        if (a + 2 < s)
            _ = (t[a] << 16) + (t[a + 1] << 8) + t[a + 2],
                n += $_EJu(e(_, 7274496)) + $_EJu(e(_, 9483264)) + $_EJu(e(_, 19220)) + $_EJu(e(_, 235));
        else {
            var c = s % 3;
            2 == c ? (_ = (t[a] << 16) + (t[a + 1] << 8),
                n += $_EJu(e(_, 7274496)) + $_EJu(e(_, 9483264)) + $_EJu(e(_, 19220)),
                r = '.') : 1 == c && (_ = t[a] << 16,
                n += $_EJu(e(_, 7274496)) + $_EJu(e(_, 9483264)),
                r = '.' + '.');
        }
    }
    return {"res": n, "end": r};
}


function h_m(t) {
    var e = h_m_$FCD(t);
    return e["res"] + e["end"];

}

function userresponse(t, e) {
    for (var n = e['slice'](-2), r = [], i = 0; i < n['length']; i++) {
        var o = n['charCodeAt'](i);
        r[i] = 57 < o ? o - 87 : o - 48;
    }

    n = 36 * r[0] + r[1];
    var s, a = Math['round'](t) + n, _ = [[], [], [], [], []], c = {}, u = 0;
    i = 0;

    for (var l = (e = e['slice'](0, -2))['length']; i < l; i++)
        c[s = e['charAt'](i)] || (c[s] = 1,
            _[u]['push'](s),
            u = 5 == ++u ? 0 : u);
    var h, f = a, d = 4, p = '', g = [1, 2, 5, 10, 50];
    while (0 < f)
        0 <= f - g[d] ? (h = parseInt(Math.random() * _[d]['length'], 10),
            p += _[d][h],
            f -= g[d]) : (_['splice'](d, 1),
            g['splice'](d, 1),
            d -= 1);
    return p;

}


function encry_gj_ct(t) {
    this['$_BCAO'] = t || [];
}

encry_gj_ct.prototype.$_CAE = function (t) {
    var e = this['$_BCAO'];
    if (e.map)
        return new encry_gj_ct(e.map(t));
    for (var n = [], r = 0, i = e.length; r < i; r += 1)
        n[r] = t(e[r], r, this);
    return new encry_gj_ct(n);
}

function encry_gj(gj_array) {
    function n(t) {
        var e = '()*,-./0123456789:?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqr'
            , n = e['length']
            , r = ''
            , i = Math['abs'](t)
            , o = parseInt(i / n);
        n <= o && (o = n - 1),
        o && (r = e['charAt'](o));
        var s = '';
        return t < 0 && (s += '!'),
        r && (s += '$'),
        s + r + e['charAt'](i %= n);
    }

    var t = function (t) {
        for (var e, n, r, i = [], o = 0, s = 0, a = t['length'] - 1; s < a; s++)
            e = Math['round'](t[s + 1][0] - t[s][0]),
                n = Math['round'](t[s + 1][1] - t[s][1]),
                r = Math['round'](t[s + 1][2] - t[s][2]),
            0 == e && 0 == n && 0 == r || (0 == e && 0 == n ? o += r : (i['push']([e, n, r + o]),
                o = 0));
        return 0 !== o && i['push']([e, n, o]),
            i;
    }(gj_array);

    var r = [], i = [], o = [];
    return new encry_gj_ct(t).$_CAE(function (t) {
        var e = function (t) {
            for (var e = [[1, 0], [2, 0], [1, -1], [1, 1], [0, 1], [0, -1], [3, 0], [2, -1], [2, 1]],
                     n = 0, r = e.length; n < r; n++)
                if (t[0] == e[n][0] && t[1] == e[n][1])
                    return 'stuvwxyz~'[n];
            return 0;
        }(t);
        e ? i['push'](e) : (r['push'](n(t[0])),
            i['push'](n(t[1]))),
            o['push'](n(t[2]));
    }),
    r['join']('') + '!!' + i['join']('') + '!!' + o['join']('');

}

function second_encry_gj(t, e, n) {
    if (!e || !n)
        return t;
    var r, i = 0, o = t, s = e[0], a = e[2], _ = e[4];
    while (r = n['substr'](i, 2)) {
        i += 2;
        var c = parseInt(r, 16)
            , u = String.fromCharCode(c)
            , l = (s * c * c + a * c + _) % t.length;
        o = o['substr'](0, l) + u + o['substr'](l);
    }
    return o;

}

function gj_aa(getphp_c, getphp_s, gj_array) {
    var gj = encry_gj(gj_array) // 先加密轨迹
    gj = second_encry_gj(gj, getphp_c, getphp_s) // 再加密轨迹，c,s
    return gj
}


var winPerformanceTiming = (function () {
    //  检测：window.performance.timing
    let now = +Date.now()
    return {
        "a":  now + 5000,
        "b": 0,
        "c": 0,
        "d": 0,
        "e": 0,
        "f": now + 5010,
        "g":  now + 5010,
        "h":  now + 5010,
        "i":  now + 5010,
        "j":  now + 5010,
        "k": 0,
        "l":  now + 5020,
        "m":  now + 5156,
        "n":  now + 5161,
        "o": now + 5165,
        "p":  now + 5341,
        "q": now + 5341,
        "r":  now + 5344,
        "s":  now + 5349,
        "t":  now + 5349,
        "u":  now + 5349
    }
})()

function o_ep() {
    return {
        $_BIE: false, // wt['touchEvent'],
        me: true, // wt['mouseEvent'],
        td: -1,
        tm: winPerformanceTiming, // 检测环境：window.performance.timing
        v: '7.9.2',
    }

}

function Vmd5(str) {
    var result = CryptoJS.MD5(str).toString();
    return result
}

function generate_w3(params) {
    var gt = params['gt'],
        challenge = params['challenge'],
        distance = params['distance'],
        passtime = params['passtime'],
        getphp_c = params['c'],
        getphp_s = params['s'],
        gj_array = params['track'],
        random16Key = params['random16Key'];
    var r = this
    var o = {
        lang: "zh-cn",
        userresponse: userresponse(distance, challenge), // 滑动距离 + challenge 的值（ "66c6f2229a4"）
        passtime: passtime, // 滑块滑动时间，毫秒 （4548）
        imgload: 40 + parseInt(Math.random() * 20), // 图片加载时间 毫秒 （61）
        aa: gj_aa(getphp_c, getphp_s, gj_array), // 轨迹加密 ("M-./11033//--/-(!!Wss(((((((((((())ssststvwstststtsssssttssssstss(!w!(o01203/3-/4-2110112$/W1E$-Y02110299$*ZFL911E$)D$.PE$Bm91$-yIUP$*_$56")
        ep: o_ep() // ep-tm：window["performance"]["timing"] 相关 ({"v": "7.9.2", "$_BIE": false,  "me": true,"tm": {... },  "td": -1})
    };

    // _gct获取随机键值对，如 ：{'h9s9': '1803797734'}

    o["h9s9"] = "1816378497"; // 会变化

    // i['offline'] && (o['x'] = distance);
    var rp_text = gt + challenge.slice(0, 32) + o['passtime']
    o['rp'] = CryptoJS.MD5(rp_text).toString();  // gt + 32 位 challenge + passtime，再经过 MD5 加密

    // var o = {
    //     "lang": "zh-cn",
    //     "userresponse": "88bbb8b8bbb88440d",
    //     "passtime": 362,
    //     "imgload": 60,
    //     "aa": "j12575410/-(!!Tst)))(((((((X(!!($m)N11W111A111111$*_",
    //     "ep": {
    //         "v": "7.9.2",
    //         "$_BIE": false,
    //         "me": true,
    //         "tm": {"a": 1702375608535, "b": 1702375611559, "c": 1702375611559, "d": 0, "e": 0, "f": 1702375608546, "g": 1702375608577, "h": 1702375608577, "i": 1702375608577, "j": 1702375608616, "k": 1702375608593, "l": 1702375608616, "m": 1702375608778, "n": 1702375608787, "o": 1702375611564, "p": 1702375611701, "q": 1702375611701, "r": 1702375611703, "s": 1702375611709, "t": 1702375611709, "u": 1702375611709},
    //         "td": -1
    //     },
    //     "h9s9": "1816378497",
    //     "rp": "1c603f696dc6ee3765637939ca2b2aeb"
    // }
    var u = genRSAesKey(random16Key) // rsa加密，生成的aes_key
    var l = aesV(JSON.stringify(o), random16Key) // aes加密，key为之前生成的aes_key
    // console.log(l, l.length)
    var h = h_m(l)  // 加密后的数组再加密转换为字符串
    // console.log(h)

    var w = h + u
    // console.log(o)
    return w
}

// **********************************
var oiStr = (function () {
    function elemList() {
        var elem = [
            'textLength', 'HTMLLength', 'documentMode', 'A', 'ARTICLE', 'ASIDE', 'AUDIO', 'BASE', 'BUTTON', 'CANVAS', 'CODE', 'IFRAME', 'IMG',
            'INPUT', 'LABEL', 'LINK', 'NAV', 'OBJECT', 'OL', 'PICTURE', 'PRE', 'SECTION', 'SELECT', 'SOURCE', 'SPAN', 'STYLE', 'TABLE', 'TEXTAREA',
            'VIDEO', 'screenLeft', 'screenTop', 'screenAvailLeft', 'screenAvailTop', 'innerWidth', 'innerHeight',
            'outerWidth', 'outerHeight', 'browserLanguage', 'browserLanguages', 'systemLanguage', 'devicePixelRatio',
            'colorDepth', 'userAgent', 'cookieEnabled', 'netEnabled', 'screenWidth', 'screenHeight', 'screenAvailWidth',
            'screenAvailHeight', 'localStorageEnabled', 'sessionStorageEnabled', 'indexedDBEnabled', 'CPUClass',
            'platform', 'doNotTrack', 'timezone', 'canvas2DFP', 'canvas3DFP', 'plugins', 'maxTouchPoints',
            'flashEnabled', 'javaEnabled', 'hardwareConcurrency', 'jsFonts', 'timestamp', 'performanceTiming',
            'internalip', 'mediaDevices', 'DIV', 'P', 'UL', 'LI', 'SCRIPT', 'touchEvent'
        ]
        // console.log(elem.length) // 74
        return elem
    }

    function ae(e) {
        this['$_BADk'] = e;
    }

    ae.prototype = {
        '$_DJp': function (e) {
            var t = this["$_BADk"];
            if (t.map) {
                return new ae(t.map(e));
            }
            for (var n = [], r = 0, o = t.length; r < o; r += 1)
                n[r] = e(t[r], r, this);
            return new ae(n);
        },
    }
    ae['$_BABe'] = function (e) {
        var $_BFECN = tLnKP.$_Ci
            , $_BFEBe = ['$_BFEFz'].concat($_BFECN)
            , $_BFEDz = $_BFEBe[1];
        $_BFEBe.shift();
        var $_BFEEe = $_BFEBe[0];
        return Array[$_BFECN(621)] ? Array[$_BFECN(621)](e) : $_BFECN(636) === Object[$_BFEDz(77)][$_BFECN(71)][$_BFECN(83)](e);
    }

    function genOI() {
        var n = this, r = {}, o = [];
        var f1 = function (e) {
            var t = r[e];
            var _ = (void 0 === t) ? -1 : t
            o.push(_);
        }
        var params = elemList();
        (new ae(params)).$_DJp(f1);
        return o.join('!!')
    }

    return genOI()
})()

function generate_w1(gt, challenge, random16Key) {

    var o = {
        "gt": gt,
        "challenge": challenge,
        "offline": false,
        "new_captcha": true,
        "product": "float",
        "width": "300px",
        "https": true,
        "api_server": "apiv6.geetest.com",
        "protocol": "https://",
        "type": "fullpage",
        "static_servers": ["static.geetest.com/", "static.geevisit.com/"],
        "beeline": "/static/js/beeline.1.0.1.js",
        "voice": "/static/js/voice.1.2.4.js",
        "click": "/static/js/click.3.1.0.js",
        "fullpage": "/static/js/fullpage.9.1.8-bfget5.js",
        "slide": "/static/js/slide.7.9.2.js",
        "geetest": "/static/js/geetest.6.0.9.js",
        "aspect_radio": {"slide": 103, "click": 128, "voice": 128, "beeline": 50},
        "cc": 8,
        "ww": true,
        "i": oiStr
    }

    var u = genRSAesKey(random16Key) // rsa加密，生成的aes_key
    var l = aesV(JSON.stringify(o), random16Key) // aes加密，key为之前生成的aes_key
    // console.log(l, l.length)
    var h = h_m(l);  // 加密后的数组再加密转换为字符串
    // console.log('>>> ', encryKey)
    var w = h + u;
    return w
}

//****************** slide-第二个w ****************
var w2gj = (function () {
    function _bhjf(e) {
        var t = ''
            , n = 0;
        (e || [])['length'];
        while (!t && e[n])
            t = e[n] && e[n][4],
                n++;
        if (!t)
            return e;
        for (var r = '', o = ['mouse', 'touch', 'pointer', 'MSPointer'], i = 0, s = o['length']; i < s; i++)
            0 === t['indexOf'](o[i]) && (r = o[i]);
        for (var a = e['slice'](), _ = a['length'] - 1; 0 <= _; _--) {
            var c = a[_]
                , l = c[0];
            if (-1 < new ae(['move', 'down', 'up'])['$_EGY'](l))
                0 !== (c[4] || '')['indexOf'](r) && a['splice'](_, 1);
        }
        return a;
    }

    function ae(e) {
        this['$_BADk'] = e || [];
    }

    ae.prototype = {
        "\u0024\u005f\u0045\u0047\u0059": function (e) {
            var t = this['$_BADk'];
            if (t['indexOf'])
                return t['indexOf'](e);
            for (var n = 0, r = t['length']; n < r; n += 1)
                if (t[n] === e)
                    return n;
            return -1;
        }
    }
    ae['$_BABe'] = function (e) {
        return Array['isArray'] ? Array['isArray'](e) : '[object Array]' === Object['prototype']['toString']['call'](e);
    }

    function _BHHl(e) {
        var t = 32767;
        return 'number' != typeof e ? e : (t < e ? e = t : e < -t && (e = -t),
            Math['round'](e));
    }

    function gjF1(e) {
        var t = 0
            , n = 0
            , r = []
            , o = this;
        var i = 0 // o['lastTime'] 0

        var s = null, a = null;
        var _ = _bhjf(e);  // 变成128位了
        var c = _['length'];

        for (var l = c < 300 ? 0 : c - 300; l < c; l += 1) {
            var u = _[l]
            var p = u[0];
            -1 < new ae(['down', 'move', 'up', 'scroll']).$_EGY(p) ? (s || (s = u),
                a = u,
                r['push']([p, [u[1] - t, u[2] - n], _BHHl(i ? u[3] - i : i)]),
                t = u[1],
                n = u[2],
                i = u[3]) : -1 < new ae(['blur', 'focus', 'unload']).$_EGY(p) && (r['push']([p, _BHHl(i ? u[1] - i : i)]),
                i = u[1]);
        }
        o['$_BGBd'] = s;
        o['$_BGCP'] = a;
        return {gj2: r, convertArray: _}
    }

    //162位
    function fj2F2(e) {
        var p = {
            "move": 0,
            "down": 1,
            "up": 2,
            "scroll": 3,
            "focus": 4,
            "blur": 5,
            "unload": 6,
            "unknown": 7
        };

        function h(e, t) {
            for (var n = e['toString'](2), r = '', o = n['length'] + 1; o <= t; o += 1)
                r += '0';
            return n = r + n;
        }

        function f(e) {
            var t = []
                , n = e['length']
                , r = 0;

            while (r < n) {
                var o = e[r]
                    , i = 0;
                while (1) {
                    if (16 <= i)
                        break;
                    var s = r + i + 1;
                    if (n <= s)
                        break;
                    if (e[s] !== o)
                        break;
                    i += 1;
                }
                r = r + 1 + i;
                var a = p[o];
                0 != i ? (t['push'](8 | a),
                    t['push'](i - 1)) : t['push'](a);
            }

            for (var _ = h(32768 | n, 16), c = '', l = 0, u = t['length']; l < u; l += 1)
                c += h(t[l], 4);
            return _ + c;
        }

        function c(e, t) {
            for (var n = [], r = 0, o = e['length']; r < o; r += 1)
                n['push'](t(e[r]));
            return n;
        }

        function d(e, t) {
            e = function _(e) {
                var t = 32767
                    , n = (e = c(e, function (e) {
                    return t < e ? t : e < -t ? -t : e;
                }))['length']
                    , r = 0
                    , o = [];
                while (r < n) {
                    var i = 1
                        , s = e[r]
                        , a = Math['abs'](s);
                    while (1) {
                        if (n <= r + i)
                            break;
                        if (e[r + i] !== s)
                            break;
                        if (127 <= a || 127 <= i)
                            break;
                        i += 1;
                    }
                    1 < i ? o['push']((s < 0 ? 49152 : 32768) | i << 7 | a) : o['push'](s),
                        r += i;
                }
                return o;
            }(e);
            var n, r = [], o = [];
            c(e, function (e) {

                var t = Math['ceil'](function n(e, t) {

                    return 0 === e ? 0 : Math['log'](e) / Math['log'](t);
                }(Math['abs'](e) + 1, 16));
                0 === t && (t = 1),
                    r['push'](h(t - 1, 2)),
                    o['push'](h(Math['abs'](e), 4 * t));
            });
            var i = r['join']('')
                , s = o['join']('');

            return n = t ? c(function a(e, t) {

                var n = [];
                return c(e, function (e) {

                    t(e) && n['push'](e);
                }),
                    n;
            }(e, function (e) {

                return 0 != e && e >> 15 != 1;
            }), function (e) {

                return e < 0 ? '1' : '0';
            })['join']('') : '',
            h(32768 | e['length'], 16) + i + s + n;
        }

        var result = function (e) {
            for (var t = [], n = [], r = [], o = [], i = 0, s = e['length']; i < s; i += 1) {
                var a = e[i];
                var _ = a['length'];
                t['push'](a[0]);
                n['push'](2 === _ ? a[1] : a[2]);
                3 === _ && (r['push'](a[1][0]),
                    o['push'](a[1][1]));
            }
            var c = f(t) + d(n, !1) + d(r, !0) + d(o, !0);
            var l = c['length'];
            l % 6 != 0 && (c += h(0, 6 - l % 6))

            function u(e) {
                for (var t = '', n = e['length'] / 6, r = 0; r < n; r += 1)
                    t += '()*,-./0123456789:?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~'['charAt'](parseInt(e['slice'](6 * r, 6 * (r + 1)), 2));
                return t;  // "M,38PjV)9U(N(,,(e(e(,g))jRj51Rj-1S0MMOE-1KTMMNj/1RkK1-2M:M9O,.mM*3BBA(5bbbq(8?O4ObV2cbK/cXnJVb9En--FI1-5I-*(Y-,b9@)(N19bM/)M0qqqb(jW)NSEK)p0jEO2HhE19VE1/5,(,(M(RN95*(*(b5)N(5,(*/,(b1(qqb"
            }

            return u(c);
        };
        return result(e);
    }

    return {gjF1, fj2F2}

})()

function ttFun(e, t, n) {
    if (!t || !n) {
        return e
    }
    ;
    var r, o = 0, i = e, s = t[0], a = t[2], _ = t[4];
    while (r = n['substr'](o, 2)) {
        o += 2;
        var c = parseInt(r, 16)
            , l = String['fromCharCode'](c)
            , u = (s * c * c + a * c + _) % e['length'];
        i = i['substr'](0, u) + l + i['substr'](u);
    }
    return i;
}

function generate_w2(params) {
    var R$_HCm = function (e) {
        for (var t = [], n = 0, r = e.length; n < r; n += 1)
            t.push(e.charCodeAt(n));
        return h_m(t);
    }

    var gt = params['gt'],
        challenge = params['challenge'],
        c = params['c'],
        s = params['s'],
        gjArray5 = params['track'],
        random16Key = params['random16Key'];

    // var gjArray5 = gjArray5;
    // var c = [12, 58, 98, 36, 43, 95, 62, 15, 12];
    // var s = "32476854"; // get.php
    // var gt = '019924a82c70bb123aae90d483087f94'
    // var challenge = 'cf813f7331f853607500399833c6bc83'

    // var w1i_val = "-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1";
    var w1i_val = oiStr;
    // var passtime = 17479;

    var nVal = "-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1magic data-1";
    // var tVal = "M(*((1((M((";
    var tVal = w2gj.fj2F2([]); // "M(*((1((M(("
    // var eVal = "M/38Pjp)CcPjp(9A3(@)99D9(b,5((7R9(b(((()).()f*I9O:S0_?/)*).lGSMENmRj31K)*GCgNVK/O)QNA)(:HUq-K)*DRkODVHH,ZI-5M9Mb-,hDVZM9-jM,h,(5((5b(,(b5)(8b58b85Y11-)1)3)M?(c6)?)NCMEW0G.61-,1)NM(?/)M2G:K4JY/-bE8)N@1n-*-Y/)M9,)(915-)M9(((((qqb)fkTj(()M/(,U(((/)j)kO57(,)b(b9)(bA,(Q2QP:4c(N6?lb15OY(hS*-OKAXWlQGU_,)MEb1)MM2(9E1,(M(b5((((Tqqj";

    var {gj2, convertArray} = w2gj.gjF1(gjArray5);
    var eVal = w2gj.fj2F2(gj2);
    var passtime = parseInt(2.1 * (convertArray.at(-1)[3] - convertArray[0][3]))
    // var passtime = 1639108;
    var params = [
        ["lang", "zh-cn"],
        ["type", "fullpage"],
        ["tt", ttFun(eVal, c, s)],
        ["light", "DIV_0"], // DIV_0  SPAN_0
        ["s", Vmd5(R$_HCm(tVal))], // M(*((1((M((
        ["h", Vmd5(R$_HCm(nVal))],
        ["hh", Vmd5(nVal)],
        ["hi", Vmd5(w1i_val)],
        ["vip_order", -1],
        ["ct", -1],
        ["ep", {
            "v": "9.1.8-bfget5",
            "$_E_": false, // "touchEvent"
            "me": true, // "mouseEvent"
            "ven": "Google Inc. (Intel)",
            "ren": "ANGLE (Intel, Intel(R) UHD Graphics 620 (0x00005917) Direct3D11 vs_5_0 ps_5_0, D3D11)",
            "fp": convertArray[0], // ["move", 1116, 264, 1706205027698, "pointermove"],
            "lp": convertArray.at(-1), // ["up", 742, 184, 1706205028815, "pointerup"],
            // 环境检测，浏览器和node
            "em": {"ph": 0, "cp": 0, "ek": "11", "wd": 1, "nt": 0, "si": 0, "sc": 0},
            "tm": winPerformanceTiming,
            "dnf": "dnf",
            "by": 0
        }
        ],
        ["passtime", passtime],
        ["rp", Vmd5(gt + challenge + passtime)]
    ]

    // console.log(params)
    var str1 = '';
    for (_ = 0; _ < params['length']; _++) {
        str1 += '"' + params[_][0] + '":' + JSON.stringify(params[_][1]) + ',';
    }
    // var paramStr = '{' + str1 + '"captcha_token":"' + 541381339 + '","gdyf":"kqy8o0w7"}';
    var paramStr = '{' + str1 + '"captcha_token":"' + 541381339 + '","otpj":"jm4jwcx7"}';
    // console.log(paramStr)
    // console.log((paramStr).length)


    // var key = "5d16ab1d1162c125";
    // var params = {
    //     "lang": "zh-cn",
    //     "type": "fullpage",
    //     "tt": "M/S8N4E4/(78P9jp39A3(?9(,9g)JB,5,0,((8((,5(,,)f-ODVU31-0S**,Q9KWA9M:-9-:(@V1-:7))lRj-1T8M9ODM9ODRjRjE1M9KDS0S0M9OE-1KDS0M9ODMMODiOE-)HE(nM8qe,e55((,5b(le(58,,:*9dM9/*(5-)MM,)(E3(/,M*/)(1-)*)M9ME-)b91g6@FED)*3b9OI-3SVOI-1T)NgNfbEAQbb8)(@0)))7)M(aqqqqb*D)jFM(EK*MM/)NM(0j((0M)Nkp2g5E1@MbNVMM2E1*F(9~RMM28(NQ*1JGj2W1f1S5,(*291/N91/9-2MA-(E5.MMF*F*F*K*)E1*9Q1E1*9E1,(M)95)MM5,(8q*6b)qqb",
    //     "light": "DIV_0",
    //     "s": "c7c3e21112fe4f741921cb3e4ff9f7cb",
    //     "h": "321f9af1e098233dbd03f250fd2b5e21",
    //     "hh": "39bd9cad9e425c3a8f51610fd506e3b3",
    //     "hi": "09eb21b3ae9542a9bc1e8b63b3d9a467",
    //     "vip_order": -1, "ct": -1, "ep": {
    //         "v": "9.1.8-bfget5",
    //         "$_E_": false, "me": true, "ven": "Google Inc. (Intel)",
    //         "ren": "ANGLE (Intel, Intel(R) UHD Graphics 620 (0x00005917) Direct3D11 vs_5_0 ps_5_0, D3D11)",
    //         "fp": ["move", 1090, 314, 1706230299450, "pointermove"],
    //         "lp": ["up", 814, 213, 1706230300988, "pointerup"],
    //         "em": {"ph": 0, "cp": 0, "ek": "11", "wd": 1, "nt": 0, "si": 0, "sc": 0},
    //         "tm": {
    //             "a": 1706230294197, "b": 1706230294428, "c": 1706230294428,
    //             "d": 0, "e": 0, "f": 1706230294198, "g": 1706230294233,
    //             "h": 1706230294233, "i": 1706230294233, "j": 1706230294314,
    //             "k": 1706230294255, "l": 1706230294314,
    //             "m": 1706230294418, "n": 1706230294423, "o": 1706230294431, "p": 1706230294727, "q": 1706230294727,
    //             "r": 1706230294728, "s": 1706230294737, "t": 1706230294737, "u": 1706230294737
    //         }, "dnf": "dnf", "by": 0
    //     },
    //     "passtime": 32559, "rp": "fdb39425ba8f913eba30fed1585384d3",
    //     "captcha_token": "541381339", "gdyf": "kqy8o0w7"
    // }

    // var params = JSON.stringify(params);
    var aesEncryArray = aesV(paramStr, random16Key);
    var w = h_m(aesEncryArray);
    return w
}


// ******************words-点选w3***************
function generateClickW3(params) {
    var gt = params['gt'],
        challenge = params['challenge'],
        c = params['c'],
        s = params['s'],
        random16Key = params['random16Key'],
        point_str = params['point_str'],
        pic = params['pic'],
        passtime = params['passtime'],
        ca = params['ca'],
        click_track =params['click_track']

    // var winper = params['winper']

    // 300长度
    // var click_track = []
    // var ca = [
    //     {"x": 885, "y": 221, "t": 1, "dt": 2676},
    //     {"x": 879, "y": 318, "t": 1, "dt": 1767},
    //     {"x": 773, "y": 362, "t": 1, "dt": 920},
    //
    //     {"x": 990, "y": 519, "t": 3, "dt": 855}
    // ]

    var eVal = w2gj.fj2F2(click_track)
    var o = {
        "lang": "zh-cn",
        "passtime": passtime,
        "a": point_str,  // "1777_2619,5886_2109,7326_7088",  //坐标
        "pic": pic, // "/captcha_v3/custom_batch/v3/85/2024-01-26T18/icon/ce1a0919079d4b53b6ccfc1e4ac87a3d.jpg",
        // 相当于aa,轨迹加密
        "tt": ttFun(eVal, c, s), //"M?b,Pj_g(j(j(j-j(jp8Mc38Pj9?Pjp8Oc38PjClPjp..*M7-(556A6.f,(5(((5n,,A-(B5(5(b6::-B,(((((5,,((--:-BD(9B((((b(,,,9:gJAb(5550,)-*JVMUNkN(ODMEN)/)*DM9NGM:-1-:-4EU-030/)*(K:GDS0S,*3M9K*O2Nj-1VU-98c/0-FKDI@AcK.*2K2K)*2KDM9OEK)**M9QM/1-110HQ-kRj-1RjRkKDRkK2K)*3CE-1KE/1Rkp2I:Nc.cS)K:PdQF/)QDM9ODMFlAR632K2KDRkKE-0ODRjS*O3G)*2K*O).j@7-1-:-)-9M:-9-AZj31K0S0MjODMEOCNMEOE-1-1Tj-1Tj5B?(aj((5,b8b(b((e((5((58n((b(5(55,(eenben8,8(n((nb8(5(ee,(bb(((eb(,q:F-QXIa5-1GUb9X)*3JMI--bA93)(?-b3.(*(R(@4*(@b9:CBgRn-1FkFkK5-.5Y-)b93)(5-)1?-*/)(W,20SU-2JUBU--61/,2*MM5N3)(9M9/.M)M9?))U/-7)(M/)()MM*)ME/(-1/)M9(9ME-U-)ME(9/)(5-)(M1)4)(E-(/)(hC1/4M9djK1/-1g3)(hME?)(PMM19M91@//(*8))TWCJR:hL*)AbU8)(N5959b93)(5-*M9)qqNqqqqp((((0M((qqqj,(9b5,,bnB.(((,(((beq(q,q58(5(b(b(b5e(((88b8((e55nb(b(-b5((,,(,8(,We7)(?(U1(-)M9(MbU/-(,K),1-9k:/NU:1B8a(UU:5Y-,2A6,:Qb96@b9951*M9,)ME-(-)M9,)(EG(-U7(b9/-M51)4)M?/)(1-*Bg_**TBgM95Q5PME1*-NMb1?*)(?MM-1/)1)19-)*)(E-(3)(1-)MM(?8)(Y-,-c5Nb91I-*@)(?,)(9b9/)()ME(@K6M9q4Id2J/)(Q6E--(@(@-PM9::M91@(NM91E-(M9-c1*M9)0.ZZqqqM(((,qq(/((((",
        "ep": {
            "ca": ca,
            "v": "3.1.0",
            "$_FB": false,
            "me": true,
            "tm": winPerformanceTiming,
        },
        "h9s9": "1816378497",
        // 6216680937717fdab947ed9e71a3aaa1 7e9c3693600ca175509da24c47a8a894 2816
        // gt + 32 位 challenge + passtime，再经过 MD5 加密
        "rp": Vmd5(gt + challenge + passtime)
    }
    var u = genRSAesKey(random16Key) // rsa加密，生成的aes_key
    var l = aesV(JSON.stringify(o), random16Key) // aes加密，key为之前生成的aes_key
    // console.log(l, l.length)
    var h = h_m(l)  // 加密后的数组再加密转换为字符串
    return h + u;
}


